﻿using System;
using System.Web.UI;
using System.Linq;

using LDAP.Entity;

namespace LDAP.Web
{
    /// <summary>
    /// 模板页基类
    /// </summary>
    public class BaseMaster : MasterPage
    {
        //private Settings _settings;

        /// <summary>
        /// 可能为null，使用的时候要记得判断
        /// </summary>
        public User CurrentUser { get; private set; }

        public bool IsLogin { get; private set; }
        
        protected override void OnInit(EventArgs e)
        {
            //NLog.Log.DefaultLog().Write("OnInit");
            base.OnInit(e);

            CurrentUser = Auth.GetUser();
            IsLogin = CurrentUser != null;
        }

        /*/// <summary>
        /// 获取当前的Action值
        /// </summary>
        protected string Action
        {
            get
            {
                return Tools.Web.Request.GetQueryString("action");
            }
        }*/


        public string R
        {
            get
            {
                return System.Configuration.ConfigurationManager.AppSettings["version"] ?? "";
            }
        }

        public string StaticDomain
        {
            get
            {
                return System.Configuration.ConfigurationManager.AppSettings["StaticDomain"] ?? "";
            }
        }

        public bool IsSuperAdministrator()
        {
            return CurrentUser.Id.ToUpper() == "CY7539";
        }

        public bool IsAngel()
        {
            return LDAP.BLL.BizAngel.IsAngel(CurrentUser.Id);
        }
    }
}